Skip to content

Conversation

@lodekeeper
Copy link

Description

Makes the column reconstruction delay constants relative to slot duration instead of hardcoded milliseconds. This ensures proper timing on networks with different slot durations.

Problem

The current implementation uses hardcoded values:

  • RECONSTRUCTION_DELAY_MIN_MS = 800
  • RECONSTRUCTION_DELAY_MAX_MS = 1200

These are based on 12s mainnet slots and don't scale properly for:

  • Gnosis Chain (5s slots)
  • Devnets with custom slot times
  • Future forks with shorter slots

Solution

Use ratios of slot duration instead:

  • RECONSTRUCTION_DELAY_MIN_RATIO = 1/15 (~6.67% of slot)
  • RECONSTRUCTION_DELAY_MAX_RATIO = 1/10 (10% of slot)

This maintains the same 800-1200ms delay for 12s slots while automatically adapting for other networks:

  • 5s slots (Gnosis): ~333-500ms
  • 6s slots: ~400-600ms

Closes #8569


This PR was authored with AI assistance (lodekeeper using Claude Opus 4).

Make reconstruction delay constants relative to slot duration instead of
hardcoded milliseconds. This ensures proper timing on networks with
different slot durations (e.g., Gnosis 5s, devnets).

Ratios maintain the same behavior for 12s slots:
- Min delay: 1/15 of slot (800ms at 12s)
- Max delay: 1/10 of slot (1200ms at 12s)

Closes ChainSafe#8569
@lodekeeper lodekeeper requested a review from a team as a code owner January 31, 2026 17:39
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @lodekeeper, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request refactors the column reconstruction delay mechanism to be dynamic and adaptive, rather than relying on static millisecond values. By introducing delay ratios relative to the network's slot duration, the system can now automatically adjust its timing for various blockchain configurations, such as those with shorter slot times, thereby enhancing compatibility and robustness across different network environments.

Highlights

  • Adaptive Reconstruction Delays: Replaced hardcoded millisecond values for column reconstruction delays with ratios relative to the network's slot duration. This ensures that the delay automatically scales with different slot times.
  • Improved Network Compatibility: The change addresses issues with networks having non-standard slot durations (e.g., Gnosis Chain's 5-second slots) and future forks, preventing timing inconsistencies.
  • Maintain Original Behavior for Mainnet: For the standard 12-second mainnet slots, the new ratio-based calculation maintains the original 800-1200ms delay range, ensuring no regression in existing behavior.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors the column reconstruction delay to be a function of the slot duration, rather than a hardcoded millisecond value. This is a great improvement that makes the timing more robust across different networks with varying slot times. The implementation is correct and follows the logic described. I have one suggestion to slightly improve performance by pre-calculating the delay range in the constructor.

Comment on lines 66 to 69
const slotMs = this.config.SECONDS_PER_SLOT * 1000;
const minDelayMs = slotMs * RECONSTRUCTION_DELAY_MIN_RATIO;
const maxDelayMs = slotMs * RECONSTRUCTION_DELAY_MAX_RATIO;
const delay = minDelayMs + Math.random() * (maxDelayMs - minDelayMs);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

For a minor performance improvement, minDelayMs and maxDelayMs could be calculated once in the constructor and stored as class properties. Since this.config.SECONDS_PER_SLOT is constant for the lifetime of the ColumnReconstructionTracker instance, this would avoid re-calculating these values on every call to triggerColumnReconstruction.

Here's how you could refactor it:

  1. Add properties to ColumnReconstructionTracker:
private readonly minDelayMs: number;
private readonly maxDelayMs: number;
  1. Initialize them in the constructor:
constructor(init: ColumnReconstructionTrackerInit) {
  // ... existing constructor logic
  const slotMs = this.config.SECONDS_PER_SLOT * 1000;
  this.minDelayMs = slotMs * RECONSTRUCTION_DELAY_MIN_RATIO;
  this.maxDelayMs = slotMs * RECONSTRUCTION_DELAY_MAX_RATIO;
}
  1. Use the properties in triggerColumnReconstruction to replace the current lines 66-69:
const delay = this.minDelayMs + Math.random() * (this.maxDelayMs - this.minDelayMs);

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The pre-calculation makes sense from a pure optimization standpoint, but I'll keep the inline calculation for now:

  1. Negligible impact — runs at most once per slot (~12s), so 2 multiplications is trivial
  2. Code clarity — the calculation inline makes the relationship between slot time and delay immediately visible
  3. Simpler class — no extra state to manage

If a maintainer prefers the constructor approach, happy to change it!

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the detailed explanation, lodekeeper. Your points regarding the negligible performance impact, improved code clarity with inline calculation, and simpler class structure are well-reasoned and valid. I agree that for this specific scenario, the current implementation is perfectly acceptable. Closing this thread.

Copy link
Author

@lodekeeper lodekeeper left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the review! The pre-calculation suggestion makes sense from a pure optimization standpoint, but I'll keep the inline calculation for now because:

  1. Negligible impact — This runs at most once per slot (~12s), so 2 multiplications per trigger is trivial
  2. Code clarity — Having the calculation inline makes the relationship between slot time and delay immediately visible
  3. Simpler class — No extra state to manage

If a maintainer prefers the constructor approach, happy to change it. But for a hot path this is not 😄

@lodekeeper
Copy link
Author

@nflaig Good point! I'll update to use BPS format to stay consistent with consensus spec conventions. Will push a commit shortly.

@lodekeeper
Copy link
Author

Done! Updated to use basis points (BPS) format:

  • RECONSTRUCTION_DELAY_MIN_BPS = 667 (6.67% → ~800ms for 12s slot)
  • RECONSTRUCTION_DELAY_MAX_BPS = 1000 (10% → 1200ms for 12s slot)

Calculation: (slotMs * BPS) / 10000

@nflaig
Copy link
Member

nflaig commented Jan 31, 2026

/gemini review

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request effectively addresses the issue of hardcoded reconstruction delays by making them relative to the slot duration. The approach of using basis points is sound and the implementation is correct. This change improves the robustness of the system on networks with different slot times. I have one suggestion to optimize the calculation of the delay values by moving it to the constructor, which would be a minor performance and code structure improvement.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Column reconstruction delay as a function of slot time

2 participants